<template>
	<view class="comp-box">
		<view class="part5">
			<view class="title-box u-flex u-row-between">
				<text class="title-text">关于我们</text>
				<button type="primary" class="save-btn" @click="$u.throttle(saveItem, 2000)">保存</button>
			</view>
			<view class="part5-con" style="min-height: 75vh;">
				<textarea value="" v-model="aboutInfo.remarks" placeholder="请输入"
					maxlength="500" style="overflow: hidden;min-height: 75vh;width: 640rpx;" />
				<view style="font-size: 24rpx;text-align: right;color: #0080FF;">
					({{aboutInfo.remarks && aboutInfo.remarks.length || 0}}/500)
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	import {
		queryUsrCompanyStationList,
		insertCompanyStation
	} from '@/common/api/auth.js'
	import {
		getToken
	} from '@/utils/token.js'
	export default {
		data() {
			return {
				aboutInfo: {}, //关于我们
			}
		},
		onLoad: function() {
			this.init()
		},
		methods: {
			// 初始化数据
			async init() {
				let res = await this.queryUsrCompanyStationList()
				if (res.data && res.data.code == 1) {
					let acInfo = {}
					// 数组分类
					let data = res.data && res.data.listData
					this.aboutInfo = data && data.find(m => {
						return m.stationType == 10
					}) || {}
				}
			},
			//公司更多数据详情
			queryUsrCompanyStationList() {
				return queryUsrCompanyStationList({
					companyNo: getToken('useNum'),
					stationType: 10
				})
			},
			saveItem() {
				let item10 = this.aboutInfo
				let params10 = [{
					remarks: item10.remarks || '',
					stationId: item10.stationId || '',
					stationType: item10.stationType || 10,
					moduleNo: item10.moduleNo || 'ydylapp1003',
					companyId: item10.companyId || getToken('useNum')
				}]
				this.editFun({
					jsonData: JSON.stringify(params10)
				})
			},
			editFun(params) {
				insertCompanyStation(params).then(res => {
					if (res.data && res.data.code == 1) {
						this.$store.commit('isFresh', true)
						uni.hideLoading()
						this.$u.toast('保存成功')
						setTimeout(()=>{
							uni.navigateBack()
						},500)
					} else {
						this.$u.toast('保存失败')
					}
				})
			},
		}
	}
</script>

<style lang="scss">
	@import "./css/edit.scss";
</style>
